//用枪射击怪兽，枪可装弹6发，每发弹杀伤力20，怪有血量110，中弹6发可消灭
#include<iostream>
#include<unistd.h>

#ifdef _WIN32
        #include<windows.h>
#endif

using std::cout;
using std::endl;

void sleep_cp(unsigned int seconds){
    #ifdef _WIN32
        Sleep(seconds * 1000);  // windows下的Sleep函数是以毫秒为单位的
    #else
        usleep(seconds * 1000000); // unix/linux下的usleep函数是以微秒为单位的
    #endif
}

class Beast
{
public:
    int blood=110;
    Beast() 
    {
    }
    void Hurt()
    {
        blood-=20;
    }
    void InfomationPrint()
    {
        cout<<"The blood rest:"<<blood<<endl;
    }
};

class Gun:public Beast
{
private:
    int bullet;
public:
    Beast *beast1=new Beast;
    Gun(int bullet)
        :bullet(bullet) {}
    void Hurt()
    {
        if(bullet) bullet--;
        else cout<<"No bullet!"<<endl;
        beast1->Hurt();
        if(beast1->blood<0) 
        {
            delete beast1;
            cout<<"The beast is dead!"<<endl;
        }
    }
    void Print()
    {
        cout<<"The bullets count:"<<bullet<<endl;
        beast1->InfomationPrint();
    }
};

int main()
{
    Gun gun1(6);
    for(int i=0;i<6;i++)
    {
        sleep_cp(1);
        gun1.Hurt();
        gun1.Print();
    }
    
    return 0;
}